<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of getDASRegistryOptions</title>
  <meta name="keywords" content="getDASRegistryOptions">
  <meta name="description" content="GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">code</a> &gt; getDASRegistryOptions.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for code&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>getDASRegistryOptions
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [optList] = getDASRegistryOptions(varargin) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry
 
GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry
that will populated SEARCHREGISTRY_GUI menus with search parameters
 
 SYNTAX: [optList] = getDASRegistryOptions(varargin)
          optList - cellstr list with the options according to the
          criteria

 EXAMPLES: 
             Get organisms' list
             [optList] = getDASRegistryOptions() or
             [optList] = getDASRegistryOptions('criteria','organism')
             
             Get coordinate sytems' list
             [optList] = getDASRegistryOptions('criteria','type')
             
             Get authorities' list
             [optList] = getDASRegistryOptions('criteria','authority')
             
             Get capabilities' list
             [optList] = getDASRegistryOptions('criteria','capability')

 See also <a href="searchRegistry_gui.html" class="code" title="function varargout = searchRegistry_gui(varargin)">SEARCHREGISTRY_GUI</a>

    DASMiner: DAS library and browser for Matlab.
    Diogo Veiga, March 2008.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>	READDASURL attempts to read the DAS URL within the specified timeout</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="searchRegistry_gui.html" class="code" title="function varargout = searchRegistry_gui(varargin)">searchRegistry_gui</a>	SEARCHREGISTRY_GUI is the GUI for DAS Registry search in Browser</li></ul>
<!-- crossreference -->

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="#_sub1" class="code">function [typesList] = parseDASXMLbyType(timeout)</a></li><li><a href="#_sub2" class="code">function [organismList] = parseDASXMLbyOrganism(timeout)</a></li><li><a href="#_sub3" class="code">function [authList] = parseDASXMLbyAuthority(timeout)</a></li><li><a href="#_sub4" class="code">function [capList] = parseDASXMLbyCapability(timeout)</a></li><li><a href="#_sub5" class="code">function [res] = isValidCriteria(x)</a></li></ul>
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [optList] = getDASRegistryOptions(varargin)</a>
0002 <span class="comment">% GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry</span>
0003 <span class="comment">%</span>
0004 <span class="comment">%GETDASREGISTRYOPTIONS extract the list of search options in DAS Registry</span>
0005 <span class="comment">%that will populated SEARCHREGISTRY_GUI menus with search parameters</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% SYNTAX: [optList] = getDASRegistryOptions(varargin)</span>
0008 <span class="comment">%          optList - cellstr list with the options according to the</span>
0009 <span class="comment">%          criteria</span>
0010 <span class="comment">%</span>
0011 <span class="comment">% EXAMPLES:</span>
0012 <span class="comment">%             Get organisms' list</span>
0013 <span class="comment">%             [optList] = getDASRegistryOptions() or</span>
0014 <span class="comment">%             [optList] = getDASRegistryOptions('criteria','organism')</span>
0015 <span class="comment">%</span>
0016 <span class="comment">%             Get coordinate sytems' list</span>
0017 <span class="comment">%             [optList] = getDASRegistryOptions('criteria','type')</span>
0018 <span class="comment">%</span>
0019 <span class="comment">%             Get authorities' list</span>
0020 <span class="comment">%             [optList] = getDASRegistryOptions('criteria','authority')</span>
0021 <span class="comment">%</span>
0022 <span class="comment">%             Get capabilities' list</span>
0023 <span class="comment">%             [optList] = getDASRegistryOptions('criteria','capability')</span>
0024 <span class="comment">%</span>
0025 <span class="comment">% See also SEARCHREGISTRY_GUI</span>
0026 <span class="comment">%</span>
0027 <span class="comment">%    DASMiner: DAS library and browser for Matlab.</span>
0028 <span class="comment">%    Diogo Veiga, March 2008.</span>
0029 
0030 p = inputParser;   <span class="comment">% Create an instance of the class.</span>
0031 
0032 p.addParamValue(<span class="string">'timeout'</span>, 90000, @isnumeric); <span class="comment">%time in miliseconds</span>
0033 p.addParamValue(<span class="string">'criteria'</span>, <span class="string">'organism'</span>, @(x) <a href="#_sub5" class="code" title="subfunction [res] = isValidCriteria(x)">isValidCriteria</a>(x));
0034 
0035 p.KeepUnmatched = true;
0036 p.FunctionName = <span class="string">'GETDASREGISTRYOPTIONS'</span>;
0037 p.parse(varargin{:});
0038 
0039 <span class="keyword">switch</span> p.Results.criteria
0040 
0041     <span class="keyword">case</span> <span class="string">'type'</span>
0042         optList = <a href="#_sub1" class="code" title="subfunction [typesList] = parseDASXMLbyType(timeout)">parseDASXMLbyType</a>(p.Results.timeout);
0043     <span class="keyword">case</span> <span class="string">'organism'</span>
0044         optList = <a href="#_sub2" class="code" title="subfunction [organismList] = parseDASXMLbyOrganism(timeout)">parseDASXMLbyOrganism</a>(p.Results.timeout);
0045     <span class="keyword">case</span> <span class="string">'authority'</span>
0046         optList = <a href="#_sub3" class="code" title="subfunction [authList] = parseDASXMLbyAuthority(timeout)">parseDASXMLbyAuthority</a>(p.Results.timeout);
0047     <span class="keyword">case</span> <span class="string">'capability'</span>
0048         optList = <a href="#_sub4" class="code" title="subfunction [capList] = parseDASXMLbyCapability(timeout)">parseDASXMLbyCapability</a>(p.Results.timeout);
0049 
0050 <span class="keyword">end</span>
0051 
0052 <a name="_sub1" href="#_subfunctions" class="code">function [typesList] = parseDASXMLbyType(timeout)</a>
0053 
0054 [xmlStruct, xml, status] = <a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>(<span class="string">'http://www.dasregistry.org/das1/coordinatesystem'</span>,timeout);
0055 
0056 <span class="keyword">if</span> (~status)
0057     <span class="comment">%error('Server is taking too long to respond. Increase timeout and try again.');</span>
0058     optList = -1;
0059     <span class="keyword">return</span>;
0060 <span class="keyword">end</span>
0061 
0062 <span class="keyword">if</span> (~isstruct(xmlStruct))
0063 <span class="comment">%     error('Problem parsing XML response.');</span>
0064     optList = -1;
0065     <span class="keyword">return</span>;
0066 <span class="keyword">end</span>
0067 
0068 typesList = {};
0069 <span class="keyword">for</span> i=1:size(xmlStruct.COORDINATES,2)
0070    
0071     list = regexp(xmlStruct.COORDINATES{i}.CONTENT,<span class="string">','</span>,<span class="string">'split'</span>);
0072     
0073     <span class="keyword">for</span> j=1:size(list,2)
0074         
0075         <span class="keyword">if</span> (~any(strcmpi(list{j},typesList)))
0076             typesList = [typesList; list{j}];
0077         <span class="keyword">end</span>
0078     <span class="keyword">end</span>
0079 <span class="keyword">end</span>
0080 typesList = sort(typesList);
0081 
0082 <a name="_sub2" href="#_subfunctions" class="code">function [organismList] = parseDASXMLbyOrganism(timeout)</a>
0083 
0084 [xmlStruct, xml, status] = <a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>(<span class="string">'http://www.dasregistry.org/das1/organism'</span>,timeout);
0085 
0086 <span class="keyword">if</span> (~status)
0087 <span class="comment">%     error('Server is taking too long to respond. Increase timeout and try again.');</span>
0088     optList = -1;
0089     <span class="keyword">return</span>;
0090 <span class="keyword">end</span>
0091 
0092 <span class="keyword">if</span> (~isstruct(xmlStruct))
0093 <span class="comment">%     error('Problem parsing XML response.');</span>
0094     optList = -1;
0095     <span class="keyword">return</span>;
0096 <span class="keyword">end</span>
0097 
0098 organismList = {};
0099 
0100 <span class="keyword">for</span> i=1:size(xmlStruct.ORGANISM,2)
0101     
0102     org = xmlStruct.ORGANISM{i}.ATTRIBUTE.scientificName;
0103 
0104     <span class="keyword">if</span> (~any(strcmpi(org,organismList)))
0105         organismList = [organismList; org];
0106     <span class="keyword">end</span>
0107     
0108 <span class="keyword">end</span>
0109 organismList = sort(organismList);
0110 
0111 <a name="_sub3" href="#_subfunctions" class="code">function [authList] = parseDASXMLbyAuthority(timeout)</a>
0112 
0113 [xmlStruct, xml, status] = <a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>(<span class="string">'http://www.dasregistry.org/das1/sources/'</span>,timeout);
0114 
0115 <span class="keyword">if</span> (~status)
0116 <span class="comment">%     error('Server is taking too long to respond. Increase timeout and try again.');</span>
0117     optList = -1;
0118     <span class="keyword">return</span>;
0119 <span class="keyword">end</span>
0120 
0121 <span class="keyword">if</span> (~isstruct(xmlStruct))
0122 <span class="comment">%     error('Problem parsing XML response.');</span>
0123     optList = -1;
0124     <span class="keyword">return</span>;
0125 <span class="keyword">end</span>
0126 
0127 authList = {};
0128 <span class="keyword">for</span> i=1:size(xmlStruct.SOURCE,2)
0129     
0130    <span class="keyword">if</span> (isfield(xmlStruct.SOURCE{i}.VERSION{1},<span class="string">'COORDINATES'</span>))
0131        
0132        <span class="keyword">for</span> k=1:size(xmlStruct.SOURCE{i}.VERSION{1}.COORDINATES,2)
0133 
0134            auth = xmlStruct.SOURCE{i}.VERSION{1}.COORDINATES{k}.ATTRIBUTE.authority;
0135 
0136            <span class="keyword">if</span> (~any(strcmpi(auth,authList)))
0137                authList = [authList; auth];
0138            <span class="keyword">end</span>
0139        <span class="keyword">end</span>
0140    <span class="keyword">end</span>
0141 <span class="keyword">end</span>
0142 
0143 authList = sort(authList);
0144 
0145 <a name="_sub4" href="#_subfunctions" class="code">function [capList] = parseDASXMLbyCapability(timeout)</a>
0146 
0147 [xmlStruct, xml, status] = <a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>(<span class="string">'http://www.dasregistry.org/das1/sources/'</span>,timeout);
0148 
0149 <span class="keyword">if</span> (~status)
0150 <span class="comment">%     error('Server is taking too long to respond. Increase timeout and try again.');</span>
0151     optList = -1;
0152     <span class="keyword">return</span>;
0153 <span class="keyword">end</span>
0154 
0155 <span class="keyword">if</span> (~isstruct(xmlStruct))
0156 <span class="comment">%     error('Problem parsing XML response.');</span>
0157     optList = -1;
0158     <span class="keyword">return</span>;
0159 <span class="keyword">end</span>
0160 
0161 capList = {};
0162 <span class="keyword">for</span> i=1:size(xmlStruct.SOURCE,2)
0163     
0164    <span class="keyword">if</span> (isfield(xmlStruct.SOURCE{i}.VERSION{1},<span class="string">'CAPABILITY'</span>))
0165        
0166        <span class="keyword">for</span> k=1:size(xmlStruct.SOURCE{i}.VERSION{1}.CAPABILITY,2)
0167 
0168            capTokens = regexp(xmlStruct.SOURCE{i}.VERSION{1}.CAPABILITY{k}.ATTRIBUTE.type,<span class="string">':'</span>,<span class="string">'split'</span>);
0169            
0170            <span class="keyword">if</span> (~any(strcmpi(capTokens{2},capList)))
0171                capList = [capList; capTokens{2}];
0172            <span class="keyword">end</span>
0173        <span class="keyword">end</span>
0174    <span class="keyword">end</span>
0175 <span class="keyword">end</span>
0176 capList = sort(capList);
0177 
0178 <a name="_sub5" href="#_subfunctions" class="code">function [res] = isValidCriteria(x)</a>
0179 
0180 res = any(strcmpi(x,{<span class="string">'type'</span>,<span class="string">'organism'</span>,<span class="string">'authority'</span>,<span class="string">'capability'</span>}));</pre></div>
<hr><address>Generated on Tue 17-Feb-2009 16:59:45 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>